package com.ssc.nav

import com.ssc.nav.extension.NavPluginExtension
import com.ssc.nav.task.NavTask
import com.ssc.nav.utils.LogUtils
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.register

class NavPlugin : Plugin<Project> {

    val mGroup = "ssc"
    val mDesc = "this is a plugin for navigation"

    val NAV_PLUGIN_EXTENSION = "navPluginConfig"
    val NAV_PLUGIN = "navPlugin"
    val PRE_BUILD = "preBuild"

    override fun apply(target: Project) {


        val navPluginConfig =
            target.extensions.create(NAV_PLUGIN_EXTENSION, NavPluginExtension::class.java)

        target.tasks.register<NavTask>(NAV_PLUGIN) {
            group = mGroup
            description = mDesc
            config.set(navPluginConfig)
        }
        target.tasks.named(PRE_BUILD){
            dependsOn(NAV_PLUGIN)
        }
    }
}